'use strict';

const { userTable } = require('../models/database_tables');

class UserService  {
  async getUserName(username) {
    try {
      const result = await userTable.where({ username }).findOne();
      return result;
    } catch (err) {
      console.log(err);
      return null;
    }
  }
  async register(params) {
    try {
      const result = await userTable.save(params);
      return result;
    } catch (err) {
      console.log(err);
      return null;
    }
  }
  async edit(params) {
    try {
      const result = await userTable.save(params);
      return result;
    } catch (err) {
      console.log(err);
      return null;
    }
  }
  async cancel(params) {
    try {
      const result = await userTable.save(params);
      return result;
    } catch (err) {
      console.log(err);
      return null;
    }
  }
}

module.exports = new UserService();
